import Qt 4.7

Item {
    id: iconcontainer
    width: 100
    height: 110
    property string iconSource: ""
    property string iconId: ""

    property alias textString: text.text
    signal clicked

    function updateIcon(state) {
        icon.source = iconSource + "_" + state + ".png";
    }

    Rectangle {
        width: parent.width
        height: parent.height
        Image {
            id: icon
            source: iconSource + "_default.png"
        }

        Text {
            id: text
            font.bold: true;
            font.family: "Nokia Sans";
            font.pixelSize: 20;
            smooth: true
            anchors.horizontalCenter: parent.horizontalCenter;
            anchors.bottom: parent.bottom
        }

        MouseArea {
            id: mousearea
            anchors.fill: parent
            onClicked: iconcontainer.clicked()
        }

        states: [
            State {
                name: "pressed";
                when: mousearea.pressed
                PropertyChanges {
                    target: icon;
                    source: iconSource + "_" + "pressed" + ".png";
                }
            },
            State {
                name: "clicked";
                when: mousearea.clicked
                PropertyChanges {
                    target: icon;
                    source: iconSource + "_" + "default" + ".png";
                }
            }
        ]
    }
}
